/*
 * MainMenu.cpp
 *
 *  Created on: Jan 5, 2009
 *      Author: Michael
 */

#include "MainMenu.h"
#include "GamePlay.h"

MainMenu *MainMenu::inst = 0;

MainMenu::MainMenu() {}

MainMenu* MainMenu::Instance()
{
	if(!inst)
	{
		inst = new MainMenu();
	}

	return inst;
}

//functions to handle initialization and clean up
void MainMenu::Init()
{
	//load texture
	HR(D3DXCreateTextureFromFile(gd3dDevice, "Textures//MMScreen.jpg", &m_MMScreen));
	m_MMScreenCenter = D3DXVECTOR3(640.0f, 512.0f, 0.0f);
}

void MainMenu::CleanUp()
{
	ReleaseCOM(m_MMScreen);
}

//functions to handle pausing and resuming a state
void MainMenu::Pause()
{

}
void MainMenu::Resume()
{

}

void MainMenu::HandleInput(Prismatic* game)
{
	if(gDInput->keyPressed(DIK_RETURN))
	{
		////skip Title Screen intro, change states to next state, for now, main menu
		////game->Quit();

		// go to actual gameplay
		game->ChangeState(GamePlay::Instance());
	}
}

void MainMenu::Render(Prismatic* game)
{
	//set flags for this render and begin
	HR(game->Sprite()->Begin(D3DXSPRITE_OBJECTSPACE | D3DXSPRITE_DONOTMODIFY_RENDERSTATE));



	//draw background, plain and simple, not doing any translations or anything
	//but if i was, they would go here as well
	HR(game->Sprite()->Draw(m_MMScreen, 0, &m_MMScreenCenter, 0, D3DCOLOR_XRGB(255, 255, 255)));
	HR(game->Sprite()->Flush());


	//be sure to end when done
	HR(game->Sprite()->End());
}

void MainMenu::Update(Prismatic* game)
{
	//if I wasn't lazy and tired (its like 3am) i'd add a timer so that at a certain point it automatically changed to the next state
}
